<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>09_事件案例-选项卡切换案例</title>
  <style>
    .nav {
      background-color: #43240c;
      color: white;
    }

    .nav-bar {
      display: flex;
      width: 1200px;
      height: 46px;
      line-height: 46px;
      margin: 0 auto;
    }

    .item {
      width: 160px;
      text-align: center;
      cursor: pointer;
    }

    .item.active {
      background-color: #fee44e;
      color: #43240c;
    }
  </style>
</head>
<body>

  <div class="nav">
    <div class="nav-bar">
      <div class="item active">首页</div>
      <div class="item">9块9包邮</div>
      <div class="item">超值大额券</div>
      <div class="item">降温急救穿搭</div>
    </div>
  </div>

  <script src="../libs/jquery-3.6.0.js"></script>

  <script>
    $(function() {
      $('.item').on('click', function() {
        $(this).addClass('active').siblings().removeClass('active')
      })
    })

  </script>
  
</body>
</html>